﻿using System.Collections.Generic;
using System.Linq;
using eProject.Model;

namespace eProject.ViewModel.Commands
{
    public class CreateScheduleItemCommand : ICommand
    {
        private readonly CommonManager _manager;
        private readonly ScheduleItemViewModel _item;

        private bool _isCanceled;
        private bool _isExecuted;

        public CreateScheduleItemCommand(CommonManager manager, ScheduleItemViewModel item)
        {
            _manager = manager;
            _item = item;
            
            
        }

        public void Execute()
        {
            if (_isExecuted) return;
            _manager.AddScheduleItem(_item);            
            _isExecuted = true;
            _isCanceled = false;
        }

        public void Unexecute()
        {
            if (_isCanceled) return;            
            _manager.DeleteScheduleItem(_item);
            _isCanceled = true;
            _isExecuted = false;
        }
    }
}
